package com.kevin.schedule;

import com.kevin.manager.BackUpDataBaseManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;

/**
 * @author dell
 * @version： ScheduledTasks.java v 1.0, 2020年02月11日 11:38
 * @Description 定时任务
 **/
@Component
public class ScheduledTasks {

    private static final Logger log = LoggerFactory.getLogger(ScheduledTasks.class);

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSS");

    @Autowired
    private BackUpDataBaseManager backUpDataBaseManager;

    /**
     * 每天下午4点50分30秒执行
     */
    @Scheduled(cron = "30 50 16 * * ?")
    public void reportCurrentTime() {
        String format = dateFormat.format(System.currentTimeMillis());
        log.info("The time is now {}", format);
        backUpDataBaseManager.exportSql(format);
    }
}
